package de.jmda.gen.java.impl;

import static org.junit.Assert.assertTrue;

import org.apache.log4j.Logger;
import org.junit.Test;

import de.jmda.gen.GeneratorException;
import de.jmda.gen.java.PackageStatementGenerator;

public class JUTDefaultPackageStatementGenerator
{
	private final static Logger LOGGER =
      Logger.getLogger(JUTDefaultPackageStatementGenerator.class);

	@Test
	public void testDefaultPackageStatementGenerator() throws GeneratorException
	{
		PackageStatementGenerator generator =
				new DefaultPackageStatementGenerator();
		
		StringBuffer generated = generator.generate();

		LOGGER.debug("generated [" + generated + "]");
		
		assertTrue(
				"unexpected packagename [" + generated + "]",
				(
						"package " +
						DefaultPackageStatementGenerator.DEFAULT_PACKAGE_NAME + ";"
				).contentEquals(generated));
	}

	@Test
	public void testDefaultPackageStatementGeneratorString()
			throws GeneratorException
	{
		String packagename = getClass().getPackage().getName();

		PackageStatementGenerator generator =
				new DefaultPackageStatementGenerator(packagename);
		
		StringBuffer generated = generator.generate();

		LOGGER.debug("generated [" + generated + "]");
		
		assertTrue(
				"unexpected packagename [" + generated + "]",
				("package " + packagename + ";").contentEquals(generated));
	}
}